Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 7 - Control Statements


Try Statements

Scripts don't always work perfectly. When a script is executed, errors can occur in the Operating System (for example, when a specified file isn't found), in an application (for example, when you specify an object that doesn't exist), and in the script itself. When an error occurs, AppleScript sends a special message known as an error message. An error message is a message that is returned by an application, AppleScript, or the Operating System if an error occurs during the handling of a command. An error message can include an error number, which is an integer that identifies the error, an error expression, which is an expression, usually a string, that describes the error, and other information.

To handle error messages, scripts can include error handlers. Error handlers are contained in compound statements, called Try statements, that define the scope of the error handlers they contain. If an error message occurs and there
is no handler for it, script execution stops.


Subtopics
Kinds of Errors
How Errors Are Handled
Writing a Try Statement
Signaling Errors in Scripts

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996